package day13.tarena.com;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TestMap {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map map = new HashMap();
		while (true) {
			System.out.println("请输入用户名");
			String name = sc.next();
			if (name.matches("^[A-Za-z0-9]{5,8}$")) {
				map.put("name", name);
				break;
			}
		}
		while (true) {
			System.out.println("请输入密码");
			String passwd = sc.next();
			if (passwd.matches("^[A-Za-z0-9]{5,8}$")) {
				map.put("passwd", passwd);
				break;
			}
		}
		while (true) {
			System.out.println("请输入email");
			String email = sc.next();
			if (email
					.matches("^[A-Za-z0-9_-]+[@][A-Za-z0-9_-]+(\\.com|\\.net|\\.com\\.cn|\\.org)$")) {
				map.put("email", email);
				break;
			}
		}
		Object obj = map.get("name");
		if (obj instanceof String) {
			String n = (String) obj;
			if (n.startsWith("li")) {
				System.out.println(map);
			}
		}
	}
}
